package com.example.backend.mapper;


import com.example.backend.pojo.Food;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FoodMapper {
    @Select("select * from food where restaurantid=#{restaurantid}")
    List<Food> getall(Integer restaurantid);

    @Select("select * from food where foodid=#{foodid}")
    Food getbyfoodid(Integer foodid);


    @Insert("insert into food (foodname,restaurantid,image,price,vipprice,introduction,sales,state) values (#{foodname},#{restaurantid},#{image},#{price},#{vipprice},#{introduction},0,1) ")
    void add(Food food);

    @Update("update food set state=0 where foodid=#{foodid}")
    void delete(Integer foodid);
    @Update("update food set state=1 where foodid=#{foodid}")
    void relive(Integer foodid);

    @Update("update food set foodname=#{foodname},introduction=#{introduction},price=#{price},vipprice=#{vipprice},image=#{image} where foodid=#{foodid}")
    void update(Food food);

    @Update("update food set sales=#{sales} where foodid=#{foodid}")
    void updatesale (@Param("foodid")Integer foodid, @Param("sales")Integer sales);

    @Select("select foodid from food where foodname= #{foodname}")
    String getfoodByFoodName(String foodname);

    @Select("select * from food where restaurantid=#{restaurantid} and commend=1")
    List<Food> getallcommend(String restaurantid);

    @Update("update food set commend=#{commend} where foodid=#{foodid}")
    void updatecommend (Integer commend,String foodid);
}
